var e = require;
var t = module;
var s = exports;
Object.defineProperty(s, "__esModule", {value: !0}), (s.playerInfo = s.gameType = s.saveCoinData = void 0);
var n,
    i = e("Excelkeyvalue"),
    o = e("index"),
    r = e("user-data"),
    a = e("guide-manager"),
    c = e("player-coin");
(s.saveCoinData = function () {}),
    ((e = n = s.gameType || (s.gameType = {}))[(e.nomal = 0)] = "nomal"),
    (e[(e.war = 1)] = "war");
(l.prototype.setShowPromp = function (e) {
    this.showPromp = e;
}),
    (l.prototype.getShowPromp = function () {
        return this.showPromp;
    }),
    (l.prototype.getLimitMaxGold = function () {
        return this.limitMaxGold;
    }),
    (l.prototype.getGuideStepCount = function () {
        return this.guideStepCount;
    }),
    (l.prototype.getRewardGold = function () {
        return this.rewardGold;
    }),
    (l.prototype.getGold = function () {
        var e = r.userData.getLocalData().gold;
        return null == e ? 0 : Number(e);
    }),
    (l.prototype.setGold = function (e) {
        r.userData.setLocalData({gold: e}), o.platform.trackUserSet({coin: e});
    }),
    (l.prototype.getGameType = function () {
        return this.curGameType;
    }),
    (l.prototype.setGameType = function (e) {
        this.curGameType = e;
    }),
    (l.prototype.getMaxCellCount = function () {
        return this.maxCellCount;
    }),
    (l.prototype.getAdsCellLock = function (e) {
        e = r.userData.getLocalData()["unlock_ads" + e];
        return null == e || e;
    }),
    (l.prototype.setAdsCellLock = function (e, t) {
        var n = {};
        (n["unlock_ads" + e] = t), r.userData.setLocalData(n);
    }),
    (l.prototype.getUnlockCell = function () {
        var e = r.userData.getLocalData().unlock_cell;
        return null == e ? i.default.GetLine(1).defaultCells : Number(e);
    }),
    (l.prototype.setUnlockCell = function (e) {
        r.userData.setLocalData({unlock_cell: e});
    }),
    (l.prototype.getLevel = function () {
        var e = r.userData.getLocalData().level;
        return null == e ? 1 : Number(e);
    }),
    (l.prototype.setLevel = function (e) {
        r.userData.setLocalData({level: e});
    }),
    (l.prototype.getNumber = function () {
        var e = r.userData.getLocalData().number;
        return null == e ? 1 : Number(e);
    }),
    (l.prototype.setNumber = function (e) {
        r.userData.setLocalData({number: e});
    }),
    (l.prototype.getCellsByIdx = function (e) {
        return r.userData.getCellsByIdx(e);
    }),
    (l.prototype.setCellsByIdx = function (e, t) {
        r.userData.setCellsByIdx(e, t);
    }),
    (l.prototype.getTargetNumbers = function () {
        var e = this.getLevel();
        if (this.targetNumbersMap.has(e)) return this.targetNumbersMap.get(e);
        var t = 6 * (e - 1) + 1,
            n = i.default.GetLine(1),
            n = [t + n.stage1, t + n.stage2, t + n.stage3, t + n.stage4, t + n.stage5];
        return this.targetNumbersMap.set(e, n), n;
    }),
    (l.prototype.upgrade = function (e, t) {
        var n = i.default.GetLine(1).defaultCells;
        this.setUnlockCell(n), this.setNumber(1);
        for (var o = i.default.GetLine(1).adsLockCount - 1; o < this.maxCellCount; o++) this.setAdsCellLock(o, !0);
        for (o = 0; o < t; o++) this.setCellsByIdx(o + 1, []);
        n = this.getLevel();
        this.setLevel(n + 1), c.playerCoin.getInitCellData();
    }),
    (l.prototype.getCurTargetNumber = function (e) {
        for (var t = this.getTargetNumbers(), n = s.playerInfo.getNumber(), o = t[0], i = 0, r = 0; r < t.length; r++) {
            var a = t[r];
            if (n < a) {
                (i = r), (o = a);
                break;
            }
        }
        e && e(o, i);
    }),
    (l.prototype.getStartTime = function () {
        var e = r.userData.getLocalData().start_time;
        return null == e ? 0 : Number(e);
    }),
    (l.prototype.setStartTime = function (e) {
        r.userData.setLocalData({start_time: e});
    }),
    (l.prototype.getGuide = function () {
        var e = r.userData.getLocalData().guide;
        return null == e && (e = a.GuideStep.NONE), Number(e);
    }),
    (l.prototype.checkGuide = function (e) {
        return null == this.guideFlag && (this.guideFlag = this.getGuide()), 0 < (this.guideFlag & e);
    }),
    (l.prototype.useGuide = function (e) {
        null == this.guideFlag && (this.guideFlag = this.getGuide()),
            (this.guideFlag |= e),
            r.userData.setLocalData({guide: this.guideFlag}),
            o.platform.trackEvent("guide", {step: this.guideFlag.toString()});
    }),
    (l.prototype.resetData = function () {
        c.playerCoin.resetCoinMaxNumber(),
            this.targetNumbersMap.clear(),
            (this.guideFlag = null),
            r.userData.setLocalDataNull();
    }),
    (l.prototype.restartData = function () {
        var e = i.default.GetLine(1).defaultCells;
        this.setUnlockCell(e), this.setNumber(1);
        for (var t = i.default.GetLine(1).adsLockCount - 1; t < this.maxCellCount; t++) this.setAdsCellLock(t, !0);
        for (t = 0; t < this.maxCellCount; t++) this.setCellsByIdx(t + 1, []);
        c.playerCoin.getInitCellData();
    }),
    (l.prototype.isHaveOverCoinMaxCount = function () {
        for (var e = c.playerCoin.getCoinMaxCount(), t = new Map(), n = 0; n < this.maxCellCount; n++)
            for (var o = this.getCellsByIdx(n + 1), i = 0; i < o.length; i++) {
                var r = o[i].num;
                if (t.has(r)) {
                    if (t.get(r) + 1 >= e) return !0;
                    t.set(r, t.get(r) + 1);
                } else t.set(r, 1);
            }
        return !1;
    }),
    (l.prototype.getUseResetCount = function () {
        var e = r.userData.getLocalData().use_reset;
        return null == e ? 0 : Number(e);
    }),
    (l.prototype.setUseResetCount = function (e) {
        r.userData.setLocalData({use_reset: e});
    }),
    (l.prototype.getUseADAreaCount = function () {
        var e = r.userData.getLocalData().use_ad_area;
        return null == e ? 0 : Number(e);
    }),
    (l.prototype.setUseADAreaCount = function (e) {
        r.userData.setLocalData({use_ad_area: e});
    }),
    (l.prototype.checkAllGuide = function () {
        for (var e = this.getGuideStepCount(), t = !1, n = 0; n < e; n++)
            s.playerInfo.checkGuide(1 << (n + 1)) || (t = !0);
        return t;
    }),
    (e = l);
function l() {
    (this.targetNumbersMap = new Map()),
        (this.guideFlag = null),
        (this.maxCellCount = 9),
        (this.rewardGold = 10),
        (this.curGameType = n.nomal),
        (this.guideStepCount = 11),
        (this.limitMaxGold = 90),
        (this.showPromp = !1);
}
s.playerInfo = new e();
